package com.cloudcc.mobile.entity;

import com.cloudcc.cloudframe.util.StringUtils;
import com.cloudcc.mobile.util.AESUtils;
import com.cloudcc.mobile.util.Tools;
import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.NotNull;

/**
 * <pre>
 *     author : 92152
 *     e-mail : xxx@xx
 *     time   : 2019/11/20
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class LoginSPModel {
    public String userName;// 用户名
    public String password; // 密码加密后的
    public boolean isAutoLogin = true;// 默认是 自动登录 记住密码
    public boolean isRememberUser = true;// 默认是记住用户名

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isAutoLogin() {
        return isAutoLogin;
    }

    public void setAutoLogin(boolean autoLogin) {
        isAutoLogin = autoLogin;
    }

    public boolean isRememberUser() {
        return isRememberUser;
    }

    public void setRememberUser(boolean rememberUser) {
        isRememberUser = rememberUser;
    }

    /**
     * 获得解密后的密码
     *
     * @return
     */
    public String getDecrypt() {
        String depassword = StringUtils.EMPTY;
        if (StringUtils.isNotBlank(password)) {
            try {
                depassword = AESUtils.decrypt(Tools.getpassword(), password);
                return depassword;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return password;
    }

    /**
     * 将明文密码 des加密成 密文
     *
     * @return 加密后的密文 2016-5-3
     */
    public String getPasswordEncrypt() {
        String enPassword = StringUtils.EMPTY;
        try {
            enPassword = AESUtils.encrypt(Tools.getpassword(), password);
            return enPassword;
        } catch (Exception e) {
            e.printStackTrace();
            return enPassword;
        }
    }
}
